<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<!--修改标记模态框-->
<div class="modal fade" id="modal-update">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">项目划库存标记修改</h4>
            </div>
            <div class="modal-body">
                <form id="editMarkForm" class="form-horizontal" role="form">
                    <input type="hidden" class="form-control" id="pimId" name="pimId">
                    <input type="hidden" id="matSpecEdit">
                    <input type="hidden" id="matLengthEdit">
                    <input type="hidden" id="matWidthEdit">
                    <input type="hidden" id="matHeightEdit">
                    <input type="hidden" id="formulaTypeEdit">
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">物料描述</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="materialDescEdit"
                                   readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">项目编号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="ityProCodeEdit"
                                   readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">项目名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="ityProNameEdit"
                                   readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">可用数量</label>
                        <div class="col-sm-4">
                            <input type="number" step="0.1" style="padding-right: 5px;"
                                   class="form-control" id="ityAvaNumEdit" readonly="readonly">
                        </div>
                        <label class="col-sm-2 control-label no-padding-right">可用重量</label>
                        <div class="col-sm-4">
                            <input type="number" step="0.1" style="padding-right: 5px;"
                                   class="form-control" id="ityAvaWeightEdit" readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">标记数量</label>
                        <div class="col-sm-4">
                            <input type="number" step="0.1" style="padding-right: 5px;"
                                   class="form-control" id="pimNumEdit" name="pimNum"
                                   autocomplete="off" placeholder="请输入标记数量">
                        </div>
                        <label class="col-sm-2 control-label no-padding-right">标记重量</label>
                        <div class="col-sm-4">
                            <input type="number" step="0.1" style="padding-right: 5px;"
                                   class="form-control" id="pimWeightEdit" name="pimWeight"
                                   autocomplete="off" placeholder="请输入标记重量">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">备注</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="pimRemarkEdit" name="pimRemark"
                                   placeholder="请输入备注">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="btn-editMark">确定</button>
            </div>
        </div>
    </div>
</div>
<!--库存在库模态框-->
<div class="modal fade" id="modal-selectStock">
    <div class="modal-dialog" style="width: 1350px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">原料项目在库明细</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header">
                                <form id="queryStockForm">
                                    <div class="row">
                                        <div class="form-inline">
                                            <div class="form-group">
                                                <label>项目编号</label>
                                                <input type="text" name="ityProCode"
                                                       class="form-control"
                                                       placeholder="请输入项目编号">
                                            </div>
                                            <div class="form-group">
                                                <label>项目名称</label>
                                                <input type="text" name="ityProName" class="form-control"
                                                       placeholder="请输入项目名称">
                                            </div>
                                            <div class="form-group">
                                                <label>原料类型</label>
                                                <input type="text" name="matTypeName"
                                                       class="form-control"
                                                       placeholder="请输入原料类型">
                                            </div>
                                            <div class="form-group">
                                                <label>原料材质</label>
                                                <input type="text" name="matQualityName" class="form-control"
                                                       placeholder="请输入原料材质">
                                            </div>
                                            <div class="form-group">
                                                <label>原料规格</label>
                                                <input type="text" name="matSpecName" class="form-control"
                                                       placeholder="请输入原料规格">
                                            </div>
                                            <div class="form-group">
                                                <label>宽度</label>
                                                <input type="number" step="0.1" name="matWidth" class="form-control"
                                                       placeholder="请输入原料宽度">
                                            </div>
                                            <div class="form-group">
                                                <label>长度</label>
                                                <input type="number" step="0.1" name="matLength" class="form-control"
                                                       placeholder="请输入原料长度">
                                            </div>
                                            <div class="form-group">
                                                <label>米重/厚度</label>
                                                <input type="number" step="0.1" name="matHeight" class="form-control"
                                                       placeholder="请输入原料米重/厚度">
                                            </div>
                                            <div class="form-group">
                                                <label>生产状态</label>
                                                <select name="proProductionStatus" class="form-control">
                                                    <option value="" selected="selected">全部</option>
                                                    <option value="-1">无状态</option>
                                                    <option value="1">未开始</option>
                                                    <option value="2">执行中</option>
                                                    <option value="3">已完成</option>
                                                    <option value="4">取消</option>
                                                    <option value="5">暂缓</option>
                                                </select>
                                            </div>
                                            <button type="button" class="btn btn-success" id="btn-selectStock">搜索
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="row" id="toolbar1">
                                <button shiro:hasPermission="matinv:matprowar:edit" type="button"
                                        class="btn btn-info"
                                        id="btn-togetherMark">
                                    批量标记
                                </button>
                            </div>
                            <div class="box-body">
                                <table id="bootstrap-stock-table">
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="padding-top: 5px;">
                <button type="button" class="btn btn-info" id="btn-selectMaterial-commit">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!--单条标记模态框-->
<div class="modal fade" id="modal-create">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">项目划库存标记</h4>
            </div>
            <div class="modal-body">
                <form id="addMarkForm" class="form-horizontal" role="form">
                    <input type="hidden" class="form-control" id="pimBeforeItyId" name="pimBeforeItyId">
                    <input type="hidden" id="matSpec">
                    <input type="hidden" id="matLength">
                    <input type="hidden" id="matWidth">
                    <input type="hidden" id="matHeight">
                    <input type="hidden" id="formulaType">
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">物料描述</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="materialDesc"
                                   readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">项目编号</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="ityProCode"
                                   readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">项目名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="ityProName"
                                   readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">可用数量</label>
                        <div class="col-sm-4">
                            <input type="number" step="0.1" style="padding-right: 5px;"
                                   class="form-control" id="ityAvaNum" readonly="readonly">
                        </div>
                        <label class="col-sm-2 control-label no-padding-right">可用重量</label>
                        <div class="col-sm-4">
                            <input type="number" step="0.1" style="padding-right: 5px;"
                                   class="form-control" id="ityAvaWeight" readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">标记数量</label>
                        <div class="col-sm-4">
                            <input type="number" step="0.1" style="padding-right: 5px;"
                                   class="form-control" id="pimNum" name="pimNum"
                                   autocomplete="off" placeholder="请输入标记数量">
                        </div>
                        <label class="col-sm-2 control-label no-padding-right">标记重量</label>
                        <div class="col-sm-4">
                            <input type="number" step="0.1" style="padding-right: 5px;"
                                   class="form-control" id="pimWeight" name="pimWeight"
                                   autocomplete="off" placeholder="请输入标记重量">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">备注</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="pimRemark" placeholder="请输入备注">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="btn-addMark">确定</button>
            </div>
        </div>
    </div>
</div>

<section class="content-header">
    <h1>
        项目划库存标记记录
    </h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label>项目编号</label>
                                    <input type="text" name="ityProCode"
                                           class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group">
                                    <label>项目名称</label>
                                    <input type="text" name="ityProName"
                                           class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label>跟踪号</label>
                                    <input type="text" name="ityTrackCode"
                                           class="form-control"
                                           placeholder="请输入跟踪号">
                                </div>
                                <div class="form-group">
                                    <label>标记人员</label>
                                    <input type="text" name="pimProposer"
                                           class="form-control" th:value="${userName}"
                                           placeholder="请输入标记人员">
                                </div>
                                <div class="form-group">
                                    <label>
                                        状态
                                    </label>
                                    <select name="pimAppStatus" class="form-control">
                                        <option value="1" selected="selected">未提交</option>
                                        <option value="2">已提交</option>
                                        <option value="3">已执行</option>
                                        <option value="4">被驳回</option>
                                        <option value="">全部</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>标记日期</label>
                                    <input type="text" class="form-control datepicker"
                                           name="startTimeQuery"
                                           readonly="readonly"/>
                                    <span>至</span>
                                    <input type="text" class="form-control datepicker"
                                           name="endTimeQuery"
                                           readonly="readonly"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn_searchMark">搜索</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="row" id="toolbar">
                    <div class="form-inline">
                        <button shiro:hasPermission="matinv:matprowar:edit" type="button"
                                class="btn btn-success"
                                id="btn-togetherCommit">
                            批量提交
                        </button>
                        <button shiro:hasPermission="matinv:matprowar:edit" type="button"
                                class="btn btn-info"
                                id="btn-addStock">
                            添加
                        </button>
                    </div>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    /**加载表格*/
    var table1, table2;

    /** 更改状态 */
    function updateStatus(id, status) {
        js.modal.confirm("确定" + (status == 0 ? "删除" : "提交") + "项目划库存标记吗？", function (result) {
            js.post({
                url: ctx + "material/proToIty/updateStatus",
                data: {
                    pimId: id,
                    pimAppStatus: status
                },
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table1);
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            })
        })
    }

    /**获取物料在库信息（模态框数据源）*/
    function openInventoryList() {
        table2 = js.table.init({
            id: "bootstrap-stock-table",
            url: ctx + "matInvManage/complex/list",
            pageSize: 100,
            showExport: false,
            toolbar: '#toolbar1',
            queryForm: "queryStockForm",
            queryData: {ityInType: 2, ityAvaWeightZeroFlg: 2},
            columns: [
                {
                    field: "checked",
                    title: '全选',
                    checkbox: true
                },
                {title: '物料描述', field: 'matNameDesc'},
                {title: '可用数量', field: 'ityAvaNum'},
                {title: '可用重量', field: 'ityAvaWeight'},
                {title: '跟踪号', field: 'ityTrackCode'},
                {title: '特殊说明', field: 'itySpec'},
                {title: '项目编号', field: 'ityProCode', width: "80"},
                {title: '项目名称', field: 'ityProName'},
                {
                    title: '生产状态', field: 'proProductionStatus',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '执行中';
                        } else if (value === 2) {
                            return '未开始';
                        } else if (value === 3) {
                            return '暂缓';
                        } else if (value === 4) {
                            return '已完成';
                        }else if (value === 5) {
                            return '取消';
                        }
                    }
                },
                {title: '回货时间', field: 'ityBackDate', width: '110'},
                {title: '库位', field: 'whiName',width:'70'},
                {
                    title: '操作', width: '80',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push("<a class='btn btn-warning btn-xs'  href='javascript:void(0);' onclick='mark(" + row.ityId + "," + JSON.stringify(row) + ")'>标记</a>");
                        return actions.join('');
                    }
                }
            ],
            rowStyle: function (row, index) {
                if (row.itySpec != null && row.itySpec.indexOf("不合格") >= 0) {
                    return {css: {"color": "red"}}
                } else {
                    return {css: {"color": "black"}}
                }
            }
        });
    }

    /** 打开标记模态框 */
    function mark(id, d) {
        $("#pimBeforeItyId").val(id);
        $("#materialDesc").val(d.matNameDesc);

        $("#ityProCode").val(d.ityProCode);
        $("#ityProName").val(d.ityProName);

        $("#ityAvaNum").val(d.ityAvaNum);
        $("#ityAvaWeight").val(d.ityAvaWeight);

        $("#matSpec").val(d.matSpecName);
        $("#matLength").val(d.matLength);
        $("#matWidth").val(d.matWidth);
        $("#matHeight").val(d.matHeight);
        $("#formulaType").val(d.matFormulaType);

        js.modal.open("modal-create");
    }

    /** 打开单条修改模态框 */
    function editMark(id, d) {
        $("#pimId").val(id);
        $("#materialDescEdit").val(d.matNameDesc);
        $("#ityProCodeEdit").val(d.ityProCode);
        $("#ityProNameEdit").val(d.ityProName);
        $("#pimNumEdit").val(d.pimNum);
        $("#pimWeightEdit").val(d.pimWeight);
        $("#pimRemarkEdit").val(d.pimRemark);

        $("#ityAvaNumEdit").val((d.ityAvaNum + d.pimNum).toFixed(1));
        $("#ityAvaWeightEdit").val((d.ityAvaWeight + d.pimWeight).toFixed(2));

        $("#matSpecEdit").val(d.matSpecName);
        $("#matLengthEdit").val(d.matLength);
        $("#matWidthEdit").val(d.matWidth);
        $("#matHeightEdit").val(d.matHeight);
        $("#formulaTypeEdit").val(d.matFormulaType);

        js.modal.open("modal-update");
    }

    $(function () {

        /** 加载列表 */
        table1 = js.table.init({
            url: ctx + "material/proToIty/markList",
            pageSize: 300,
            showExport: false,
            columns: [
                {
                    field: "checked",
                    title: '全选',
                    checkbox: true,
                    formatter: function (value, row, index) {
                        if (row.pimAppStatus === 1) {
                            return {
                                disabled: false
                            }
                        } else {
                            return {
                                disabled: true
                            }
                        }
                    }
                },
                {title: '物料描述', field: 'matNameDesc'},
                {title: '跟踪号', field: 'ityTrackCode'},
                {title: '项目编号', field: 'ityProCode'},
                {title: '项目名称', field: 'ityProName'},
                {title: '标记数量', field: 'pimNum'},
                {title: '标记重量', field: 'pimWeight'},
                {
                    title: '状态', field: 'pimAppStatus', width: '80',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '<span class="badge bg-gray">未提交</span> ';
                        } else if (value === 2) {
                            return '<span class="badge bg-yellow">已提交</span> ';
                        } else if (value === 3) {
                            return '<span class="badge bg-green">已执行</span> ';
                        } else if (value === 4) {
                            return '<span class="badge bg-red">被驳回</span> ';
                        }
                    }
                },
                {title: '标记人员', field: 'pimProposer'},
                {title: '标记时间', field: 'pimDate', width: '90'},
                {title: '库位', field: 'whiName'},
                {
                    title: '操作', width: '140',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.pimAppStatus === 1 || row.pimAppStatus === 4) {
                            if (hasP("matinv:matprowar:edit") && (row.pimAccount === sessionUser.account || sessionUser.account === "admin")) {
                                actions.push("<a class='btn btn-warning btn-xs'  href='javascript:void(0);' onclick='editMark(" + row.pimId + "," + JSON.stringify(row) + ")'>修改</a>");
                            }
                            if (hasP("matinv:matprowar:del") && (row.pimAccount === sessionUser.account || sessionUser.account === "admin")) {
                                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="updateStatus(' + row.pimId + ',0)"> 删除</a>');
                            }
                            if (hasP("matinv:matprowar:edit") && (row.pimAccount === sessionUser.account || sessionUser.account === "admin")) {
                                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0);" onclick="updateStatus(' + row.pimId + ',2)" >提交</a>');
                            }
                        }
                        return actions.join('');
                    }
                }
            ]
        });

        /** 表格搜索 */
        $("#btn_searchMark").click(function () {
            js.table.search(table1);
        });

        /**打开项目在库模态框*/
        $("#btn-addStock").on('click', function () {
            openInventoryList();
            js.modal.open("modal-selectStock")
        });

        /** 表格搜索库存在库 */
        $("#btn-selectStock").click(function () {
            js.table.search(table2);
        });

        /**关闭项目在库模态框*/
        js.modal.hideEvent("modal-selectStock", function () {
            js.table.destroy(table2);
            js.reset("queryStockForm");
        });

        /**标记数量变更 联动标记重量*/
        $("#pimNum").change(function () {

            var spec = $("#matSpec").val();
            var length = $("#matLength").val();
            var width = $("#matWidth").val();
            var height = $("#matHeight").val();
            var needQty = $("#pimNum").val();
            var formulaType = $("#formulaType").val();

            var totalWeight = returnMaterialWeight(spec, length, width, height, needQty, formulaType);
            $("#pimWeight").val(totalWeight);
        });

        /**关闭单条标记模态框*/
        js.modal.hideEvent("modal-create", function () {
            js.reset("addMarkForm");
        });

        /**保存单条项目划库存标记*/
        $("#btn-addMark").click(function () {

            var pimWeight = $("#pimWeight").val();
            if (pimWeight == null || pimWeight == "") {
                js.modal.warning("请输入标记重量！");
                $("#pimWeight").focus();
                return false;
            }

            var pimNum = $("#pimNum").val();
            var ityAvaNum = $("#ityAvaNum").val();
            var ityAvaWeight = $("#ityAvaWeight").val();

            if (pimNum != null && pimNum != "" && ityAvaNum != null && ityAvaNum != "" && parseFloat(pimNum) > parseFloat(ityAvaNum)) {

                js.modal.warning("标记数量大于可用数量！");
                $("#pimNum").focus();
                return false;
            }

            if (pimWeight != null && pimWeight != "" && ityAvaWeight != null && ityAvaWeight != "" && parseFloat(pimWeight) > parseFloat(ityAvaWeight)) {

                js.modal.warning("标记重量大于可用重量！");
                $("#pimWeight").focus();
                return false;
            }

            js.validSubmit({
                formId: "addMarkForm",
                url: ctx + "material/proToIty/save",
                data: new FormData($("#addMarkForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.hide("modal-create");
                        js.modal.success("操作成功");
                        js.table.refresh(table1);
                        js.table.refresh(table2);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            });
        })

        /**标记数量变更 联动标记重量*/
        $("#pimNumEdit").change(function () {

            var spec = $("#matSpecEdit").val();
            var length = $("#matLengthEdit").val();
            var width = $("#matWidthEdit").val();
            var height = $("#matHeightEdit").val();
            var needQty = $("#pimNumEdit").val();
            var formulaType = $("#formulaTypeEdit").val();

            var totalWeight = returnMaterialWeight(spec, length, width, height, needQty, formulaType);
            $("#pimWeightEdit").val(totalWeight);
        });

        /**修改单条库存划项目标记*/
        $("#btn-editMark").click(function () {

            var pimWeight = $("#pimWeightEdit").val();
            if (pimWeight == null || pimWeight == "") {
                js.modal.warning("请输入标记重量！");
                $("#pimWeightEdit").focus();
                return false;
            }

            var pimNum = $("#pimNumEdit").val();
            var ityAvaNum = $("#ityAvaNum").val();
            var ityAvaWeight = $("#ityAvaWeight").val();

            if (pimNum != null && pimNum != "" && ityAvaNum != null && ityAvaNum != "" && parseFloat(pimNum) > parseFloat(ityAvaNum)) {

                js.modal.warning("标记数量大于可用数量！");
                $("#pimNumEdit").focus();
                return false;
            }

            if (pimWeight != null && pimWeight != "" && ityAvaWeight != null && ityAvaWeight != "" && parseFloat(pimWeight) > parseFloat(ityAvaWeight)) {

                js.modal.warning("标记重量大于可用重量！");
                $("#pimWeightEdit").focus();
                return false;
            }

            js.validSubmit({
                formId: "editMarkForm",
                url: ctx + "material/proToIty/edit",
                data: new FormData($("#editMarkForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.hide("modal-update");
                        js.modal.success("操作成功");
                        js.table.refresh(table1);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            });
        })

        /** 批量标记 */
        $("#btn-togetherMark,#btn-selectMaterial-commit").click(function () {

            var rows = js.table.selectRows("bootstrap-stock-table");

            // 如果没有选择，显示提示信息
            if (rows.length == 0) {
                js.modal.warning("请至少选择一条明细");
                return false;
            } else {
                var arr = js.table.selectColumns(table2, "ityId");
                js.post({
                    url: ctx + "material/proToIty/togetherMark",
                    contentType: "application/json",
                    data: JSON.stringify(arr),
                    success: function (result) {
                        js.modal.success(result.msg);
                        js.table.refresh(table1);
                        js.table.refresh(table2);
                    }
                })
            }
        });

        /** 批量提交 */
        $("#btn-togetherCommit").click(function () {

            var rows = js.table.selectRows("bootstrap-table");

            // 如果没有选择，显示提示信息
            if (rows.length == 0) {
                js.modal.warning("请至少选择一条明细");
                return false;
            } else {
                var arr = js.table.selectColumns(table1, "pimId");
                js.post({
                    url: ctx + "material/proToIty/togetherCommit",
                    contentType: "application/json",
                    data: JSON.stringify(arr),
                    success: function (result) {
                        if (result.type === web_status.SUCCESS) {
                            js.modal.success(result.msg);
                            js.table.refresh(table1);
                        } else {
                            js.modal.warning(result.msg);
                            js.table.refresh(table1);
                        }
                        js.modal.closeLoading();

                    }
                })
            }
        });
    })


</script>
</body>
</html>